package servlet.usuario;

import bean.BeanSession;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by juanky on 7/12/14.
 */
public class login extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        BeanSession bean = new BeanSession();
        if (bean.login(request.getParameter("username_txt"), request.getParameter("password_txt"))) {
            request.getSession().setAttribute("bean", bean);
        }
        response.sendRedirect(request.getContextPath() + "/index.jsp");
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
